/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package uit.qlks.controller.ctbaocaothang;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.sql.rowset.WebRowSet;
import uit.ejb.bo.ctbaocaothang.CTBaoCaoThangBORemote;
import uit.ejb.bo.ctbaocaothang.CTBaoCaoThangBORemoteHome;
import uit.ejb.dto.CTBaoCaoThangDTO;

/**
 *
 * @author Restart
 */
public class CTBaoCaoThangController {

    private static Context ctx;
    private static CTBaoCaoThangBORemoteHome phome;
    private static CTBaoCaoThangBORemote ctbct;

    public CTBaoCaoThangController(){

    }

    public static void Register(){
        try{
            ctx = new InitialContext();
            Object obj = ctx.lookup("ejb/CTBaoCaoThangBO");
            phome = (CTBaoCaoThangBORemoteHome) PortableRemoteObject.narrow(obj, CTBaoCaoThangBORemoteHome.class);
            ctbct =phome.create();
        }
        catch(Exception e){
        }
    }

    public static boolean ctBaoCaoThang_Insert(CTBaoCaoThangDTO ctbaocaothang) {
        try{
            Register();
            return ctbct.ctBaoCaoThang_Insert(ctbaocaothang);
        }catch(Exception e){
            return false;
        }
    }

    public static boolean ctBaoCaoThang_Update(CTBaoCaoThangDTO ctbaocaothang) {
        try{
            Register();
            return ctbct.ctBaoCaoThang_Update(ctbaocaothang);
        }catch(Exception e){
            return false;
        }
    }

    public static WebRowSet ctBaoCaoThang_GetByAll() {
        try{
            Register();
            return ctbct.ctBaoCaoThang_GetByAll();
        }catch(Exception e){
            return null;
        }
    }

    public static WebRowSet ctBaoCaoThang_GetByTop(String top, String where, String order) {
        try{
            Register();
            return ctbct.ctBaoCaoThang_GetByTop(top, where, order);
        }catch(Exception e){
            return null;
        }
    }

    public static boolean ctBaoCaoThang_Delete(String id) {
        try{
            Register();
            return ctbct.ctBaoCaoThang_Delete(id);
        }catch(Exception e){
            return false;
        }
    }
}
